
package com.gamatechno.solodestinationnew.adapter;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ImageView;
import android.widget.TextView;

import com.gamatechno.solodestinationnew.R;

public class AdapterSelectLang extends BaseAdapter {

    private LayoutInflater inflater;
    private int[] icon;
    private String[] title;

    public AdapterSelectLang(Context context, int[] icon, String[] title) {
        inflater = LayoutInflater.from(context);
        this.title = title;
        this.icon = icon;
    }

    @Override
    public int getCount() {
        return title.length;
    }

    @Override
    public Object getItem(int arg0) {
        return title[arg0];
    }

    @Override
    public long getItemId(int arg0) {
        return 0;
    }

    static class Holder {
        TextView title;
        ImageView thumb;
    }

    @Override
    public View getView(int pos, View view, ViewGroup parent) {
        Holder holder;
        if (view == null)
        {
            view = inflater.inflate(R.layout.item_select_lang, null);

            holder = new Holder();
            holder.title = (TextView) view.findViewById(R.id.title_lang);
            holder.thumb = (ImageView) view.findViewById(R.id.thumb_flag);
            view.setTag(holder);
        } else
        {
            holder = (Holder) view.getTag();
        }

        holder.title.setText(title[pos]);
        holder.thumb.setBackgroundResource(icon[pos]);

        return view;
    }
}
